﻿CREATE FUNCTION dbo.MenuAttribute
( @ProcID sysname,
	@MenuID int = NULL
)RETURNS bit
AS
BEGIN

DECLARE @AttrName sysname SET @AttrName = CASE ISNUMERIC(@ProcID) WHEN 0 THEN @ProcID ELSE REVERSE(dbo.GetTokenLeft(REVERSE(OBJECT_NAME(@PROCID)),'_')) END
DECLARE @AttrValue sysname,@Attrs nvarchar(4000) SELECT @Attrs = Attributes FROM t_Menu WHERE MenuID = @MenuID


WHILE dbo.LEN(@Attrs) > 0 BEGIN
	SET @AttrValue = dbo.GetTokenLeft(@Attrs,',')
	IF @AttrValue = @AttrName RETURN 1
	SET @Attrs = dbo.GetTokenRight(@Attrs,',')
END


RETURN 0
END

